package com.tocean.app.service.common;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tocean.app.controller.request.paper.PaperSearchDto;
import com.tocean.app.controller.request.paper.PaperTopicDto;
import com.tocean.app.controller.request.wrongset.WrongSetDto;
import com.tocean.app.dto.response.BasePageResponse;
import com.tocean.app.entity.common.PaperTopic;
import com.tocean.app.entity.common.TestPaper;
import com.tocean.app.entity.common.WrongSet;
import com.tocean.app.mapper.common.PaperTopicMapper;
import com.tocean.app.mapper.common.WrongSetMapper;
import com.tocean.app.util.id.UUIDGenerate;
import io.micrometer.core.instrument.util.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class WrongSetService {
    @Autowired
    private WrongSetMapper wrongSetMapper;


    public BasePageResponse<WrongSet> page(PaperSearchDto params, Integer page, Integer size) {
        Page<WrongSet> _page = new Page(page,size);
        IPage<WrongSet> list = wrongSetMapper.getList(_page,params);
        return new BasePageResponse().setTotal(list.getTotal()).setData(list.getRecords());
    }


    public  void AddStem(String uid,String tid) {
        WrongSet wrongSet = new WrongSet(uid,tid);
        wrongSetMapper.insert(wrongSet);
    }

    public void delete(String uid,String tid) {

        try {
            wrongSetMapper.deleteByUTId(uid,tid);

        }catch (Exception e) {

        }
    }

    public List<WrongSet> query(String uid) {
        List<WrongSet> list = wrongSetMapper.selectByUId(uid);
        return list;
    }
}
